const getVueTemplate = (componenetName) => `
<div class="detail-query-panel">
<el-form
  :model="${componenetName}Info"
  ref="baseForm"
  :inline="true"
  label-width="120px"
  label-position="left"
  class="demo-ruleForm"
  :rules="${componenetName}Rules"
  :disabled="isView"
  @submit.native.prevent
>
  <el-form-item label="外协单位">
    <el-input
      placeholder=""
      v-model="${componenetName}Info.outUnit"
      v-restrict="{ maxLength: 32 }"
    ></el-input>
  </el-form-item>
  <el-form-item label="投考F品数" prop="failQty">
    <el-input
      placeholder=""
      v-model="${componenetName}Info.failQty"
      v-restrict="{ maxLength: 32, regExp: /^[1-9]\d{0,8}$/ }"
    ></el-input>
  </el-form-item>
  <el-form-item label="随行单号" prop="parentLotNo">
    <el-input v-model="${componenetName}Info.parentLotNo" disabled>
      <i
        v-if="${componenetName}Info.parentLotNo ? true : false"
        class="el-icon-circle-close"
        @click="${componenetName}Info.parentLotNo = ''"
        slot="append"
      ></i>
      <el-button
        slot="append"
        icon="el-icon-search"
        @click="showDialog('lotNoDialog')"
      ></el-button>
    </el-input>
  </el-form-item>
  <el-form-item label="返工开始工序" prop="startNodeId">
    <el-select v-model="${componenetName}Info.startNodeId" clearable placeholder="">
      <el-option v-for="(item, index) in []" :key="index" :label="item.label" :value="item.value">
      </el-option>
    </el-select>
  </el-form-item>
  <el-form-item label="预计完成时间" prop="preCompleteTime" label-width="120px">
    <el-date-picker
      v-model="${componenetName}Info.preCompleteTime"
      value-format="yyyy-MM-dd"
      label-format="yyyy-MM-dd"
      type="date"
    >
    </el-date-picker>
  </el-form-item>
  <br />
  <el-form-item label="备注" class="long-item">
    <el-input
      placeholder=""
      type="textarea"
      v-model="${componenetName}Info.remarks"
      v-restrict="{ maxLength: 32 }"
    ></el-input>
  </el-form-item>
</el-form>
</div>`;
const getDataTemplate = (componenetName) => `
${componenetName}Info: {
  outUnit: '',
  parentLotNo: '',
  failQty: '',
  startNodeId: '',
  preCompleteTime: '',
  remarks: '',
},
${componenetName}Rules: {
  parentLotNo: [{ required: true, message: '请选择随行单号', trigger: 'change' }],
  failQty: [{ required: true, message: '请输入不良品数量', trigger: 'change' }],
  startNodeId: [{ required: true, message: '请选择返工开始工序', trigger: 'change' }],
  preCompleteTime: [{ required: true, message: '请输入预计完成时间', trigger: 'change' }],
},
`;
const getModifyTemplate = (componenetName) => [
  //template
  {
    repeatReg: new RegExp(`:model=['"]${componenetName}['"]`),
    targetReg: /(<\/\S*>[\s]*<\/template>[\s]*?<script>)/,
    tagetReplace: `${getVueTemplate(componenetName)}\n$1`,
  },
  // 定义data
  {
    repeatReg: new RegExp(`${componenetName}Info:\\s*\\{`),
    targetReg: /data\(\)\s*{([\s]*?)return[\s]*{/,
    tagetReplace: `data\(\) {$1return {
     ${getDataTemplate(componenetName)} `,
  },
];
module.exports = {
  getModifyTemplate,
};
